<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>
		<link rel="stylesheet" type="text/css" href="../css/collection.css"/>
	<script type="text/javascript" src="../js/jquery-2.0.3.js"></script>
	<script type="text/javascript" src="../js/rem.js"></script>
		<script type="text/javascript">
			$(window).load(function() {
				$('#box').delay(300).show()
			})
		</script>
	</head>
	<body>
		<!--页面加载 开始-->
		  <!--<div id="preloader">
		    <div id="status">
		      <p class="center-text"><span>拼命加载中···</span></p>
		    </div>
		  </div>-->
		  <!--页面加载 结束--> 
		<div id="box">
	  	<!--头部-->
			<header class="collection-top">
				<i onclick="goBack()" class="iconfont">&#xe621;</i>
				<h2>我的收藏</h2>
				<p class="collection-delect">编辑</p>
			</header>
			<!--内容区-->
			<section class="collection-cont">
				<!--<div class="collection-content">
				 	<img src="../img/ban.jpg"/>
				 	<p>VP战队重回世界之巅全程回顾</p>
				 	<p>Dotaer | DOTA2 /03'09"</p>
				 	<i class="iconfont mycollection-delect">&#xe62e;</i>
				</div>
				<div class="collection-content">
				 	<img src="../img/ban.jpg"/>
				 	<p>VP战队重回世界之巅全程回顾</p>
				 	<p>Dotaer | DOTA2 /03'09"</p>
				 	<i class="iconfont mycollection-delect">&#xe62e;</i>
				</div>-->
				<div class="collection-content-foot">无更多人内容</div>
			</section>
	  </div>
	<body>
	</body>
	<script type="text/javascript" src="../js/reset.js"></script>
	<script type="text/javascript" src="../js/jquery-2.0.3.js"></script>
	<script type="text/javascript" src="../js/iscroll.js"></script>
	<script type="text/javascript">
		
		/*收藏列表*/
	   var b=localStorage.getItem("user_id")
	   console.log(b)
		$.ajax({
            type: 'POST',
            url: 'http://192.168.199.114:8080/HJF/user/get_collect_list.do',
            dataType: 'JSON',
            data:{user_id:b},
            success: function(data){
            	console.log(data)
            	$.each(data.data.video_list,function(index){
            		var oDiv=$('<div class="collection-content">'+
				 	'<img src="'+data.data.video_list[index].video_img_url+'"/>'+
				 	'<p>'+data.data.video_list[index].video_title+'</p>'+
				 	'<p>'+data.data.video_list[index].channel_name+' | '+data.data.video_list[index].video_label_name+' / '+data.data.video_list[index].video_time+'</p>'+
				 	'<i class="iconfont mycollection-delect">&#xe62e;</i>'+
				'</div>')
            	oDiv.insertBefore($('.collection-content-foot'))
            	})
            	var num=0; 
				$('.collection-delect').click(function(e){ 
				if(num++ %2 == 0){ 
				$('.mycollection-delect').show()
				 $('.mycollection-delect').on('click',function(){
				 	var _this=$(this).parent().index()
				 	console.log(_this)
				 	var videoid=data.data.video_list[_this].video_id
				 	$.ajax({
			            type: 'POST',
			            url: 'http://192.168.199.114:8080/HJF/user/cancel_collect_video.do',
			            dataType: 'JSON',
			            data:{user_id:b,video_id:videoid},
			            success: function(data){ 
			             console.log(data)
			            },
			            error: function(xhr, type){
			                alert('Ajax error!');
			            }
			        });
				   $(this).parent().remove()  
			     })
				}else{ 
				$('.mycollection-delect').css('display','none')
				} 
				e.preventDefault(); //阻止元素的默认动作（如果存在） 
				}); 
            },
            error: function(xhr, type){
                alert('Ajax error!');
            }
        });
	</script>
</html>
